home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0829.dms / q0829.adf / Rexx / DIYreko.ifx
Text File  |  1997-04-10  |  25KB  |  627 lines

  1. /*
  2.  * $VER DIYreko 1.1 (3.2.95)
  3.  *
  4.  * An Arexx script for ImageFX
  5.  * For creation of .REKO data files compatible with
  6.  * Reko-Productions Klondike-Deluxe-AGA 1.3 and Klondike II
  7.  * Written by Tomasz Nidecki (TONID)
  8.  * Contact: tonid@falcon.mimuw.edu.pl or tonid@bull.mimuw.edu.pl
  9.  *
  10.  * Certain ideas borrowed from Thomas Krehbiel's Snapshot 1.04.00
  11.  * and his JPEG 1.00.00 included in ImageFX Release 1.50
  12.  *
  13.  * Compatible with ImageFX 1.50 and up
  14.  *
  15.  * This script lets you automatically build a .REKO file for
  16.  * Reko-Productions Klondike game out of a series of cropped and/or
  17.  * scaled images. This script provides scaling, enhancing, framing,
  18.  * card symbols, also rendering to a correct palette and generating a
  19.  * .REKO file.
  20.  *
  21.  * Feel free to modify this script to your convenience, but please refrain
  22.  * from spreading your versions of the script. Send them to the author
  23.  * instead, suggesting changes and enhancements. They might be included in 
  24.  * the next version of the archive.
  25.  * 
  26.  * This release opens a new class of programs called RecognitionWare. All I
  27.  * ask from you for using this script is please mention the fact that You
  28.  * used DIYreko for the creation of your .REKO set somewhere in one of the
  29.  * cards. Don't forget to mention Reko-Productions, too!
  30.  *
  31.  * For detailed description of the use of this script, read the accompanying
  32.  * .guide file! Without it you might have problems using this program.
  33.  *
  34.  * This script is richly commented to your convenience. I'm sorry if it
  35.  * makes it a bit unclear at first, but when you start reading it, you'll
  36.  * appreciate the comments.
  37.  */
  38.  
  39. OPTIONS RESULTS   /* make Arexx return results from various functions */
  40.  
  41. SIGNAL ON BREAK_C   /* allow user to stop the reko creation process */
  42.  
  43. /* Clean up after previous unsuccessful uses of DIYreko and other commands*/
  44. Redraw Off   /* first turn off the redrawing of the image buffer */
  45. ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#? ADD d'   /* delete all DIYreko temporary files from RAM */
  46. ADDRESS COMMAND 'Delete RAM:__DIYreko#? QUIET'
  47. KillBuffer force   /* kill all buffers */
  48. Swap
  49. KillBuffer force
  50. KillBrush force
  51. Render close   /* kill the render screen */
  52. Redraw On
  53.  
  54. /* Retrieve previous values from the environment */
  55. cardbase   = GETCLIP('IFX_DIYreko_CardBase')   /* path to the source cards with basename*/
  56. tempdir    = GETCLIP('IFX_DIYreko_TempDir')   /* directory where DIYreko will store temporary files */
  57. destfile   = GETCLIP('IFX_DIYreko_DestFile')   /* directory where the created .REKO file will be put */
  58. red        = GETCLIP('IFX_DIYreko_Red')   /* the red component of the background colour */
  59. green      = GETCLIP('IFX_DIYreko_Green')   /* the green component of the background colour */
  60. blue       = GETCLIP('IFX_DIYreko_Blue')   /* the blue component of the background colour */
  61. enhance    = GETCLIP('IFX_DIYreko_Enhance')   /* flag - enhance pictures using contrast and sharpen? */
  62. useframe   = GETCLIP('IFX_DIYreko_UseFrame')   /* flag - use frame on cards? */
  63. usepad     = GETCLIP('IFX_DIYreko_UsePad')   /* flag - use pad under Aces or use given cards */
  64. cutedge    = GETCLIP('IFX_DIYreko_CutEdge')   /* flag - cut card edges or not */
  65. settype    = GETCLIP('IFX_DIYreko_SetType')   /* how many cards in the set (55/59/68) */
  66.  
  67. /* If empty values are returned from the environment, set these to the following: */
  68. IF cardbase   = '' THEN cardbase   = "ImageFX:Reko/Card"
  69. IF tempdir    = '' THEN tempdir    = "SYS:Trashcan/"
  70. IF destfile   = '' THEN destfile   = "ImageFX:Reko/Card.REKO"
  71. IF red        = '' THEN red        = 154
  72. IF green      = '' THEN green      = 0
  73. IF blue       = '' THEN blue       = 48
  74. IF enhance    = '' THEN enhance    = 1
  75. IF useframe   = '' THEN useframe   = 1
  76. IF usepad     = '' THEN usepad     = 1
  77. IF cutedge    = '' THEN cutedge    = 1
  78. IF settype    = '' THEN settype    = 0
  79.  
  80. /* Prepare gadgets for the complex requester */
  81. Gadget.1  = 'T/140/20/200/0/Card basename:/'cardbase
  82. Gadget.2  = 'T/140/35/200/0/Temporary dir:/'tempdir
  83. Gadget.3  = 'T/140/50/200/0/Destination file:/'destfile
  84. Gadget.4  = 'J/140/65/30/Background:  R:/'red
  85. Gadget.5  = 'J/225/65/30/G:/'green
  86. Gadget.6  = 'J/310/65/30/B:/'blue
  87. Gadget.7  = 'X/140/80/Enhance pictures?/'enhance
  88. Gadget.8  = 'X/140/95/Use frame?/'useframe
  89. Gadget.9  = 'X/140/110/Use pad?/'usepad
  90. Gadget.10 = 'X/140/125/Cut Edges?/'cutedge
  91. Gadget.11 = 'C/140/140/Version:/3/55 Cards/59 Cards/68 Cards/0'
  92.  
  93. /* Enable complex requester using defined gadgets */
  94. ComplexRequest '"DIYreko options:"' 11 Gadget 360 170
  95. IF rc ~= 0 THEN Call BREAK_C   /* if anything goes wrong better exit from the macro */
  96.  
  97. /* Get results from the complex requester and store them in the variables */
  98. cardbase   = result.1
  99. tempdir    = result.2
  100. destfile   = result.3
  101. red        = result.4
  102. green      = result.5
  103. blue       = result.6
  104. enhance    = result.7
  105. useframe   = result.8
  106. usepad     = result.9
  107. cutedge    = result.10
  108. settype    = result.11
  109.  
  110. /* process the directory names so they include slashes or colons */
  111. IF (RIGHT(tempdir,1)~='/') & (RIGHT(tempdir,1)~=':') THEN tempdir = tempdir||'/'
  112.  
  113. /* Store the given values in the environment for the next call to DIYreko */
  114. CALL SETCLIP('IFX_DIYreko_CardBase',cardbase)
  115. CALL SETCLIP('IFX_DIYreko_TempDir',tempdir)
  116. CALL SETCLIP('IFX_DIYreko_DestFile',destfile)
  117. CALL SETCLIP('IFX_DIYreko_Red',red)
  118. CALL SETCLIP('IFX_DIYreko_Green',green)
  119. CALL SETCLIP('IFX_DIYreko_Blue',blue)
  120. CALL SETCLIP('IFX_DIYreko_Enhance',enhance)
  121. CALL SETCLIP('IFX_DIYreko_UseFrame',useframe)
  122. CALL SETCLIP('IFX_DIYreko_UsePad',usepad)
  123. CALL SETCLIP('IFX_DIYreko_CutEdge',cutedge)
  124. CALL SETCLIP('IFX_DIYreko_SetType',settype)
  125.  
  126. /* Copy frame, symbol and Prefs files to RAM for faster access */
  127. IF useframe THEN DO
  128.   ADDRESS COMMAND 'Copy >NIL: 'cardbase'Frame TO RAM:__DIYreko_framefile__'
  129.   IF rc ~= 0 THEN Call BREAK_FrameNotFound
  130. END
  131. ADDRESS COMMAND 'Copy >NIL: 'cardbase'Symbols TO RAM:__DIYreko_symbolfile__'
  132. IF rc ~= 0 THEN Call BREAK_SymbolNotFound
  133. IF settype = 2 THEN DO
  134.   ADDRESS COMMAND 'Copy >NIL: 'cardbase'Prefs TO RAM:__DIYreko_prefsfile__'
  135.   IF rc ~= 0 THEN Call BREAK_PrefsNotFound
  136. END
  137. IF useframe THEN Message "Frame and symbols copied to RAM:"
  138. ELSE Message "Symbols copied to RAM:"
  139.  
  140. /* Some startup actions */
  141. Undo Off   /* save memory by turning undo off - this kills the undo buffer too */
  142. LockInput   /* lock the input to prevent the user from messing around with the GUI while the script is working */
  143.  
  144. Blend 100   /* set blending mode to full */
  145. EdgeMode Normal   /* no edge operations (like antialiasing) will be performed */
  146. Transparency Include 0 Exclude 0   /* nothing should be considered transparent */
  147.  
  148. /* Process the card 00 - the only thing we can do with it is scale it */
  149. Message "Phase 1 - Processing Card 00"   /* 'message' outputs text to the Arexx bar on ImageFX toolbox screen */
  150. Redraw Off
  151. LoadBuffer cardbase||'00' force   /* load the card killing the previous buffer */
  152. IF rc ~= 0 THEN Call BREAK_CardNotFound   /* jump to a correct subroutine if something goes wrong */
  153. toobig = 0
  154. GetMain   /* get some info about the card */
  155. Parse var result name picwidth picheight .   /* 'parse' is an Arexx instruction which changes a string into separate variables */
  156. IF (picwidth>88) | (picheight>130) THEN toobig = 1   /* will we need to sharpen the picture? We only do it if it was scaled to be smaller */
  157. IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130   /* if not the right size, scale it */
  158. IF toobig THEN DO
  159.   IF enhance THEN DO
  160.     Contrast 10   /* a great tip from snapshot.ifx macro - nicely enhances the small image */
  161.     Sharpen 40   /* continuing... */
  162.   END
  163. END
  164. Redraw On
  165. SaveBufferAs ILBM tempdir||'__DIYreko_Card00__' force   /* save the card overwriting any older versions of it */
  166. IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  167.  
  168. /* Make the card 01 - this is the card showing empty space
  169.  * we will make it appear recessed into the background by a neat little trick
  170.  * this card will also have a sign with my alias on it :)
  171.  * Whatever you do, please do not modify this part - this is the only thing
  172.  * I would like in return for using this macro by you - recognition for my work
  173.  * However do not hesitate to put a string like "made using DIYreko by TONID"
  174.  * somewhere else in the cardset
  175.  * ATTENTION: The card 01 from the source will be IGNORED. I decided to force
  176.  * this kind of action, since I saw a couple of sets where someone put a picture
  177.  * in this place, and it highly confused the player (try StarTrek.reko and you'll
  178.  * see what I mean)
  179.  */
  180. Message "Phase 1 - Processing Card 01"
  181. CreateBuffer 88 130 force   /* make a buffer sized like a standard card */
  182. Redraw Off
  183. SetPalette '-1' Red Green Blue   /* force the given colour components into the current drawing colour */
  184. FilledBox 0 0 88 130   /* fill the buffer with the active colour */
  185. BoxRegion 0 0 0 129   /* select the left edge of the picture */
  186. BoxRegion 0 0 87 0 add   /* add to it the top edge */
  187. Brightness (-30)   /* make it darker */
  188. BoxRegion 87 0 87 129   /* select the right edge */
  189. BoxRegion 0 129 87 129 add   /* and the bottom one */
  190. Brightness 30   /* make it brighter */
  191. Region full   /* return to processing of the full image */
  192. GetPixel 0 0   /* what colour is pixel 0 0 */
  193. darkercolour = result   /* we save the colour for further use when rendering */
  194. SetPalette '-1' darkercolour /* set drawing colour to the same as the dark edges */
  195. bx = 60   /* set up base x position for the signoff */
  196. by = 122   /* same for y */
  197. Point bx by   /* make a trial point */
  198. BoxRegion bx by bx by   /* set region to this point only */
  199. Brightness (-30)   /* darken it even more - we do this to obtain an even darker colour */
  200. Region full   /* full region again */
  201. GetPixel bx by
  202. evendarkercolour = result
  203. SetPalette '-1' evendarkercolour /* set drawing colour to even darker than the dark edges */
  204. Line bx by (bx+4) by   /* start drawing my signoff - horizontal part of t */
  205. Line bx+2 (by+1) (bx+2) (by+4) /* vertical part of t */
  206. Line (bx+4) (by+2) (bx+4) (by+3) /* left edge of o */
  207. Line (bx+6) by (bx+7) by   /* top edge of o */
  208. Line (bx+8) (by+1) (bx+8) (by+3) /* right edge of o */
  209. Line (bx+5) (by+4) (bx+7) (by+4) /* bottom edge of o */
  210. Line (bx+10) by (bx+10) (by+4) /* left edge of n */
  211. Line (bx+10) by (bx+13) by   /* top edge of n */
  212. Line (bx+14) (by+1) (bx+14) (by+4) /* right edge of n */
  213. Line (bx+16) by (bx+18) by   /* top of i */
  214. Line (bx+17) (by+1) (bx+17) (by+3) /* vertical part of i */
  215. Line (bx+16) (by+4) (bx+18) (by+4) /* bottom of i */
  216. Line (bx+20) by (bx+23) by   /* top edge of d */
  217. Line (bx+24) (by+1) (bx+24) (by+3) /* right edge of d */
  218. Line (bx+20) (by+4) (bx+23) (by+4) /* bottom edge of d */
  219. Line (bx+20) (by+2) (bx+20) (by+3) /* left edge of d */
  220. GetPixel 87 129   /* similar operation with a light colour */
  221. lightercolour = result
  222. SetPalette '-1' lightercolour
  223. bx = 61
  224. by = 123
  225. Point bx by
  226. BoxRegion bx by bx by
  227. Brightness (30)
  228. Region full
  229. GetPixel bx by
  230. evenlightercolour = result
  231. SetPalette '-1' evenlightercolour
  232. Line bx by (bx+4) by
  233. Line bx+2 (by+1) (bx+2) (by+4)
  234. Line (bx+4) (by+2) (bx+4) (by+3)
  235. Line (bx+6) by (bx+7) by
  236. Line (bx+8) (by+1) (bx+8) (by+3)
  237. Line (bx+5) (by+4) (bx+7) (by+4)
  238. Line (bx+10) by (bx+10) (by+4)
  239. Line (bx+10) by (bx+13) by
  240. Line (bx+14) (by+1) (bx+14) (by+4)
  241. Line (bx+16) by (bx+18) by
  242. Line (bx+17) (by+1) (bx+17) (by+3)
  243. Line (bx+16) (by+4) (bx+18) (by+4)
  244. Line (bx+20) by (bx+23) by
  245. Line (bx+24) (by+1) (bx+24) (by+3)
  246. Line (bx+20) (by+4) (bx+23) (by+4)
  247. Line (bx+20) (by+2) (bx+20) (by+3)
  248. Redraw On
  249. SaveBufferAs ILBM tempdir||'__DIYreko_Card01__' force
  250. IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  251.  
  252. /* And now for the back-card - card 02 */
  253. Message "Phase 1 - Processing Card 02"
  254. Redraw Off
  255. LoadBuffer cardbase||'02' force
  256. IF rc ~= 0 THEN Call BREAK_CardNotFound
  257. GetMain
  258. Parse var result name picwidth picheight .
  259. IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130
  260. IF enhance THEN DO
  261.   Contrast 10
  262.   Sharpen 40
  263. END
  264. IF cutedge THEN DO   /* let's cut the edges if the user wants to */
  265.   SetPalette '-1' Red Green Blue
  266.   Point 0 0   /* all four corners to background colour */
  267.   Point 87 0
  268.   Point 0 129
  269.   Point 87 129
  270. END
  271. Redraw On
  272. SaveBufferAs ILBM tempdir||'__DIYreko_Card02__' force
  273. IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  274.  
  275. /* And now for the main loop - processing of game cards 02 to 54 */
  276. actualset = 0
  277. actualcard = 0
  278. DO cardnumber = 3 TO 54
  279.   Message "Phase 1 - Processing Card "||RIGHT(cardnumber,2,'0')
  280.   Redraw off
  281.   LoadBuffer cardbase||RIGHT(cardnumber,2,'0') force   /* add a leading 0 to the number */
  282.   IF rc ~= 0 THEN Call BREAK_CardNotFound
  283.   GetMain
  284.   Parse var result name picwidth picheight .
  285.   IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130
  286.   IF enhance THEN DO
  287.     Contrast 10
  288.     Sharpen 40
  289.   END
  290.   IF useframe THEN DO
  291.     Swap   /* switch to the other buffer */
  292.     LoadBuffer 'RAM:__DIYreko_framefile__' force  /* load the frame from RAM: to save time */
  293.     IF rc ~= 0 THEN Call BREAK_RAMFrameNotFound
  294.     IF cardnumber = 3 THEN DO   /* find the frame colour to set the right render palette later on */
  295.       GetPixel 3 3   /* an example pixel from a frame - that's where a symbol will be, so the frame colour should be underneath it */
  296.       framecolour = result
  297.     END
  298.     Matte 0 0 0   /* put the frame over the card image, treating black (0 0 0) as transparent - now this is your new card image*/
  299.   END
  300.   Swap  
  301.   LoadBuffer 'RAM:__DIYreko_symbolfile__' force  /* load the symbols into the buffer from RAM: */
  302.   IF rc ~= 0 THEN Call BREAK_RAMSymbolNotFound
  303.   IF cardnumber = 3 THEN DO   /* do it only for the first card, no sense in repeating it 52 times */
  304.     GetMain  
  305.     Parse var result name bufwidth bufheight .
  306.     symbolwidth = (bufwidth % 13)  
  307.     symbolheight = (bufheight % 4)
  308.   END
  309.   Scissors   /* prepare to cut the brush - this ImageFX instruction makes the next instruction after it act as a scissors for a brush to be cut */
  310.   Box (actualcard * symbolwidth) (actualset * symbolheight) symbolwidth symbolheight   /* this will cut the brush NOT draw a box */
  311.   CreateBuffer 88 130 force   /* make a new card buffer in place of the symbols */
  312.   BrushHandle 0 0   /* hold the brush by its top-left corner */
  313.   Point (87-symbolwidth) 1   /* put the symbols in the corners */
  314.   Point 1 (129-symbolheight)  
  315.   KillBrush force  
  316.   Matte 0 0 0  
  317.   IF cutedge THEN DO  
  318.     SetPalette '-1' Red Green Blue  
  319.     Point 0 0  
  320.     Point 87 0
  321.     Point 0 129
  322.     Point 87 129
  323.   END
  324.   Redraw On
  325.   SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__' force  
  326.   IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  327.   actualset = actualset + 1   /* change the symbol positions to be cut the next time we process a card */
  328.   IF (actualset > 3) THEN DO
  329.     actualset = 0
  330.     actualcard = actualcard + 1
  331.   END
  332. END  
  333.  
  334. /* If the cardset is of the extended type - with 4 extra cards, process them too */
  335. IF settype > 0 THEN DO
  336.   IF usepad THEN DO   /* if the user selected a pad - a card four times as wide to be used underneath the Aces */
  337.     Redraw Off
  338.     LoadBuffer cardbase||'Pad' force   /* load the pad file */
  339.     IF rc ~= 0 THEN Call BREAK_CardNotFound
  340.     GetMain  
  341.     Parse var result name picwidth picheight .
  342.     IF (picwidth~=352) | (picheight~=130) THEN Scale 352 130  
  343.     IF enhance THEN DO
  344.       Contrast 10  
  345.       Sharpen 40
  346.     END
  347.     Swap
  348.     CreateBuffer 88 130 force  
  349.     Swap
  350.     DO i = 0 TO 3
  351.       Message "Phase 1 - Processing Card "||RIGHT((55+i),2,'0')
  352.       Crop (88*i) 0 88 130 ToSwap   /* put a part of the picture into the other buffer */
  353.       Swap  
  354.       Redraw On
  355.       SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT((55+i),2,'0')||'__' force  
  356.       IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  357.       Redraw Off
  358.       Swap  
  359.     END
  360.   END
  361.   ELSE DO   /* if the user would rather process ready-made cards to be put under the Aces */
  362.     DO cardnumber = 55 TO 58
  363.       Redraw Off
  364.       Message "Phase 1 - Processing Card "||RIGHT(cardnumber,2,'0')
  365.       LoadBuffer cardbase||RIGHT(cardnumber,2,'0') force  
  366.       IF rc ~= 0 THEN Call BREAK_CardNotFound
  367.       GetMain  
  368.       Parse var result name picwidth picheight .
  369.       IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130  
  370.       IF enhance THEN DO
  371.         Contrast 10  
  372.         Sharpen 40
  373.       END
  374.       Redraw On
  375.       SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__' force  
  376.       IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  377.     END
  378.   END
  379. END
  380.  
  381. /* And if the cardset is of the extra-extended type - process the prefs cards */
  382. IF settype = 2 THEN DO
  383.   Redraw Off
  384.   LoadBuffer cardbase||"Texture" force   /* load the texture file */
  385.   IF rc ~= 0 THEN Call BREAK_TextureNotFound
  386.   GetMain  
  387.   Parse var result name picwidth picheight .
  388.   IF (picwidth~=88) | (picheight~=130) THEN Scale 88 130  
  389.   Swap  
  390.   DO i = 0 TO 8
  391.     Redraw Off
  392.     Message "Phase 1 - Processing Card "||RIGHT((i+59),2,'0')
  393.     LoadBuffer "RAM:__DIYreko_prefsfile__" force   /* load the prefs file */
  394.     IF rc ~= 0 THEN Call BREAK_RAMPrefsNotFound
  395.     Crop (88*i) 0 88 130   /* cut out the correct prefs frame */
  396.     Matte 0 0 0   /* put the texture under the frame */
  397.     IF cutedge THEN DO  
  398.       SetPalette '-1' Red Green Blue  
  399.       Point 0 0  
  400.       Point 87 0
  401.       Point 0 129
  402.       Point 87 129
  403.     END
  404.     Redraw On
  405.     SaveBufferAs ILBM tempdir||'__DIYreko_Card'||RIGHT((i+59),2,'0')||'__' force  
  406.     IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  407.   END
  408. END
  409.  
  410. /* Clean up, because we need as much memory as possible */
  411. Redraw Off
  412. KillBuffer force  
  413. swap
  414. KillBuffer force
  415. KillBrush force
  416. Render close
  417. ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#?__ ADD d'
  418. ADDRESS COMMAND 'Delete RAM:__DIYreko#?__ QUIET'
  419. ADDRESS COMMAND 'Which >T:__DIYreko_flushfound__ Flush#?'  /* find a flush command - I use one and it sometimes saves me some memory, so if the user has it, use it! */
  420. ADDRESS COMMAND 'Execute T:__DIYreko_flushfound__'   /* if found, execute it */
  421. ADDRESS COMMAND 'Delete T:__DIYreko#?__ QUIET'
  422. Redraw On
  423.  
  424. /* Prepare a buffer for rendering the palette */
  425. Redraw Off
  426. CreateBuffer (7 * 88) (4 * 130) force
  427.  
  428. /* Load images into the buffer side by side
  429.  * unfortunately, due to memory limitations, we can only
  430.  * load about 30 images, but it should be enough to get
  431.  * the correct palette, as long as we select the ones that matter:
  432.  * the first three, and if it's an extended cardset, also numbers 55 to 58
  433.  * and at least one of the prefs cards in order to get the colours from the
  434.  * prefs texture - best use cards 62 and 67 - select card and about card,
  435.  * since they contain the most elements which could matter for the
  436.  * base colours selection.
  437.  *
  438.  * If you are one of the lucky people with 10 MB ram or something like that
  439.  * feel free to change this part to consider all cards (should be easy enough).
  440.  * However, this will only lengthen the processing time and will do little good for
  441.  * the quality of the cardset, unless every card is completely different when it
  442.  * comes to colours
  443.  */
  444. xp = 0   /* current x position */
  445. yp = 0   /* current y position */
  446. Message "Phase 2 - Preparing palette"
  447. chosenend = 27   /* choose how many standard cards we can take */
  448. IF settype = 1 THEN chosenend = 23
  449. IF settype = 2 THEN chosenend = 21
  450. DO i = 0 TO chosenend
  451.   LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force  
  452.   IF rc ~= 0 THEN Call BREAK_TempFileNotFound
  453.   BrushHandle 0 0  
  454.   Point (xp * 88) (yp * 130)  
  455.   xp = xp + 1  
  456.   IF (xp > 6) THEN DO  
  457.     xp = 0
  458.     yp = yp + 1  
  459.   END
  460. END
  461. IF settype > 0 THEN DO
  462.   DO i = 55 TO 58
  463.     LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force  
  464.     IF rc ~= 0 THEN Call BREAK_TempFileNotFound
  465.     BrushHandle 0 0  
  466.     Point (xp * 88) (yp * 130)  
  467.     xp = xp + 1  
  468.     IF (xp > 6) THEN DO  
  469.       xp = 0
  470.       yp = yp + 1  
  471.     END
  472.   END
  473. END
  474. IF settype = 2 THEN DO
  475.   DO i = 62 TO 67 BY 5
  476.     LoadBrush tempdir||'__DIYreko_Card'||RIGHT(i,2,'0')||'__' force  
  477.     IF rc ~= 0 THEN Call BREAK_TempFileNotFound
  478.     BrushHandle 0 0  
  479.     Point (xp * 88) (yp * 130)  
  480.     xp = xp + 1  
  481.     IF (xp > 6) THEN DO  
  482.       xp = 0
  483.       yp = yp + 1  
  484.     END
  485.   END
  486. END
  487. KillBrush force
  488.  
  489. /* Prepare rendering module */
  490. SetRender 'Amiga'
  491. Render Mode PAL HIRES HAM LACE
  492. Render Colors 64   /* max number of base colours in HAM8 */
  493. Render Dither 0 0 0   /* no dithering needed in HAM8 */
  494.  
  495. /* Render the big buffer to obtain the best palette, adjust and lock it */
  496. LockRange 0 off   /* unlock the palette - it might have been locked before */
  497. Palette 8   /* we switch to the render palette */
  498. VisibleColors 64   /* show 64 colors on screen - needed to use HAM base colors for rendering */
  499. RenderPalette   /* render a palette */
  500. SortPalette Up   /* sort it - darkest to lightest */
  501. SetPalette 0 red green blue   /* set the background colour */
  502. GetPalette 20   /* move the colours 20 and 24 to the first locations which don't matter too much */
  503. temppalette = result
  504. SetPalette 1 temppalette
  505. GetPalette 24
  506. temppalette = result
  507. SetPalette 2 temppalette
  508. SetPalette 20 darkercolour   /* set the now free colours 20 and 24 for the sprites selecting the cards in the game */
  509. SetPalette 24 lightercolour
  510. IF useframe THEN SetPalette 5 framecolour
  511. SetPalette 3 255 0 0   /* red - used for symbols */
  512. SetPalette 4 0 0 1   /* almost black - used for symbols */
  513. SetPalette 5 evendaarkercolour   /* these are necessary so that the TONID logo appears sharp :) */
  514. SetPalette 6 evenlightercolour
  515. LockRange 0 on   /* lock the render palette so no loaded image can change it and all will use the same one */
  516. VisibleColors 32  
  517. KillBuffer force  
  518. Redraw On
  519.  
  520. /* Now reload all the pictures and render them into the correct colours */
  521. Redraw Off
  522. lastcard = 54   /* establish the correct last card number */
  523. IF settype = 1 THEN lastcard = 58
  524. IF settype = 2 THEN lastcard = 67
  525. DO cardnumber = 0 TO lastcard
  526.   Message "Phase 3 - Rendering Card "||RIGHT(cardnumber,2,'0')
  527.   LoadBuffer tempdir||'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__' force  
  528.   IF rc ~= 0 THEN Call BREAK_TempFileNotFound
  529.   Render Go
  530.   SaveRenderedAs ILBM tempdir||'__DIYreko_Rendered'||RIGHT(cardnumber,2,'0') force  
  531.   IF rc ~= 0 THEN Call BREAK_CannotSaveCard
  532.   ADDRESS COMMAND 'Delete 'tempdir'__DIYreko_Card'||RIGHT(cardnumber,2,'0')||'__ QUIET'
  533.   Render Close  
  534. END
  535.  
  536. /* Clean up to save as much RAM as possible */
  537. KillBuffer force
  538. swap
  539. KillBuffer force
  540. KillBrush force
  541. Render close  
  542. ADDRESS COMMAND 'Which >T:__DIYreko_flushfound__ Flush#?' 
  543. ADDRESS COMMAND 'Execute T:__DIYreko_flushfound__'  
  544. ADDRESS COMMAND 'Delete T:__DIYreko#?__ QUIET'
  545.  
  546. /* Generate the .REKO file in RAM: */
  547. Message "Phase 4 - Generating .REKO datafile"
  548. IF settype = 0 THEN ADDRESS COMMAND 'Reko 'tempdir'__DIYreko_Rendered00 55'
  549. IF settype = 1 THEN ADDRESS COMMAND 'Reko 'tempdir'__DIYreko_Rendered00 59'
  550. IF settype = 2 THEN ADDRESS COMMAND 'Reko 'tempdir'__DIYreko_Rendered00 68'
  551.  
  552. /* And move the freshly created REKO file to your destination directory */
  553. ADDRESS COMMAND 'Copy FROM RAM:card.reko TO 'destfile' QUIET BUF=64'   /* small copy buffer due to little memory available */
  554.  
  555. /* Finally - delete the temporary files */
  556. ADDRESS COMMAND 'Protect >NIL: 'tempdir'__DIYreko#? ADD d'
  557. ADDRESS COMMAND 'Delete 'tempdir'__DIYreko#? QUIET'
  558. ADDRESS COMMAND 'Delete RAM:card.reko QUIET'
  559.  
  560. RequestNotify 'Operation Completed Successfully.'   /* show a requester with an OK button */
  561. Undo On  
  562. UnlockInput   /* restore input so that a user can use the GUI again */
  563. EXIT   /* here the execution ends */
  564.  
  565.  
  566.  
  567. /* Exceptions, executed only if a call was made to one of them: */
  568.  
  569. BREAK_FrameNotFound:
  570. RequestNotify 'Frame file cannot be accessed - check path and files'
  571. Call BREAK_C   /* all exceptions end in the same way as if we pressed the close button on the Arexx titlebar */
  572.  
  573. BREAK_SymbolNotFound:
  574. RequestNotify 'Symbol file cannot be accessed - check path and files'
  575. Call BREAK_C
  576.  
  577. BREAK_PrefsNotFound:
  578. RequestNotify 'Prefs file cannot be accessed - check path and files'
  579. Call BREAK_C
  580.  
  581. BREAK_TextureNotFound:
  582. RequestNotify 'Texture file cannot be accessed - check path and files'
  583. Call BREAK_C
  584.  
  585. BREAK_RAMFrameNotFound:
  586. RequestNotify 'Frame file in RAM cannot be accessed'
  587. Call BREAK_C
  588.  
  589. BREAK_RAMSymbolNotFound:
  590. RequestNotify 'Symbol file in RAM cannot be accessed'
  591. Call BREAK_C
  592.  
  593. BREAK_RAMPrefsNotFound:
  594. RequestNotify 'Prefs file in RAM cannot be accessed'
  595. Call BREAK_C
  596.  
  597. BREAK_CardNotFound:
  598. RequestNotify 'Card file cannot be accessed - check path and files'
  599. Call BREAK_C
  600.  
  601. BREAK_CannotSaveCard:
  602. RequestNotify 'Cannot save file - check path, protection bits and free disk space'
  603. Call BREAK_C
  604.  
  605. BREAK_TempFileNotFound:
  606. RequestNotify 'Cannot find temp file'
  607. Call BREAK_C
  608.  
  609. /* In case of a break signalled */
  610. BREAK_C:
  611.  
  612. Message "Exiting DIYreko"
  613. UnlockInput
  614. KillBuffer force
  615. swap
  616. KillBuffer force
  617. KillBrush force
  618. Render close
  619. Undo On
  620. Redraw On
  621.  
  622. ADDRESS COMMAND 'Protect >NIL: RAM:__DIYreko#?__ ADD d'
  623. ADDRESS COMMAND 'Delete RAM:__DIYreko#?__ QUIET'
  624. ADDRESS COMMAND 'Protect >NIL: 'tempdir'__DIYreko#?__ ADD d'
  625. ADDRESS COMMAND 'Delete 'tempdir'__DIYreko#?__ QUIET'
  626. EXIT
  627.